<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>QtWebApp: stefanfrings::TemplateLoader Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">QtWebApp
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('classstefanfrings_1_1TemplateLoader.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="#pro-attribs">Protected Attributes</a> &#124;
<a href="classstefanfrings_1_1TemplateLoader-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">stefanfrings::TemplateLoader Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Loads localized versions of template files.  
 <a href="classstefanfrings_1_1TemplateLoader.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="templateloader_8h_source.html">templateloader.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for stefanfrings::TemplateLoader:</div>
<div class="dyncontent">
<div class="center"><img src="classstefanfrings_1_1TemplateLoader__inherit__graph.png" border="0" usemap="#astefanfrings_1_1TemplateLoader_inherit__map" alt="Inheritance graph"/></div>
<map name="astefanfrings_1_1TemplateLoader_inherit__map" id="astefanfrings_1_1TemplateLoader_inherit__map">
<area shape="rect" title="Loads localized versions of template files." alt="" coords="5,80,217,107"/>
<area shape="rect" href="classstefanfrings_1_1TemplateCache.html" title="Caching template loader, reduces the amount of I/O and improves performance on remote file systems." alt="" coords="7,155,215,181"/>
<area shape="rect" title=" " alt="" coords="74,5,149,32"/>
</map>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>
<div class="dynheader">
Collaboration diagram for stefanfrings::TemplateLoader:</div>
<div class="dyncontent">
<div class="center"><img src="classstefanfrings_1_1TemplateLoader__coll__graph.png" border="0" usemap="#astefanfrings_1_1TemplateLoader_coll__map" alt="Collaboration graph"/></div>
<map name="astefanfrings_1_1TemplateLoader_coll__map" id="astefanfrings_1_1TemplateLoader_coll__map">
<area shape="rect" title="Loads localized versions of template files." alt="" coords="5,80,217,107"/>
<area shape="rect" title=" " alt="" coords="74,5,149,32"/>
</map>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a25c1d61e6acd79e35feb71ac20751f30"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstefanfrings_1_1TemplateLoader.html#a25c1d61e6acd79e35feb71ac20751f30">TemplateLoader</a> (const QSettings *settings, QObject *parent=nullptr)</td></tr>
<tr class="memdesc:a25c1d61e6acd79e35feb71ac20751f30"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructor.  <a href="classstefanfrings_1_1TemplateLoader.html#a25c1d61e6acd79e35feb71ac20751f30">More...</a><br /></td></tr>
<tr class="separator:a25c1d61e6acd79e35feb71ac20751f30"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6914af0af09bc3f0e00f373c23e79382"><td class="memItemLeft" align="right" valign="top"><a id="a6914af0af09bc3f0e00f373c23e79382"></a>
virtual&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstefanfrings_1_1TemplateLoader.html#a6914af0af09bc3f0e00f373c23e79382">~TemplateLoader</a> ()</td></tr>
<tr class="memdesc:a6914af0af09bc3f0e00f373c23e79382"><td class="mdescLeft">&#160;</td><td class="mdescRight">Destructor. <br /></td></tr>
<tr class="separator:a6914af0af09bc3f0e00f373c23e79382"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a20a9bf4c48bd07fe1c358d02b09d408a"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classstefanfrings_1_1Template.html">Template</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstefanfrings_1_1TemplateLoader.html#a20a9bf4c48bd07fe1c358d02b09d408a">getTemplate</a> (const QString templateName, const QString locales=QString())</td></tr>
<tr class="memdesc:a20a9bf4c48bd07fe1c358d02b09d408a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get a template for a given locale.  <a href="classstefanfrings_1_1TemplateLoader.html#a20a9bf4c48bd07fe1c358d02b09d408a">More...</a><br /></td></tr>
<tr class="separator:a20a9bf4c48bd07fe1c358d02b09d408a"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr class="memitem:a4d63f9937e5f32de412f2b909eba7b4b"><td class="memItemLeft" align="right" valign="top">virtual QString&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstefanfrings_1_1TemplateLoader.html#a4d63f9937e5f32de412f2b909eba7b4b">tryFile</a> (const QString localizedName)</td></tr>
<tr class="memdesc:a4d63f9937e5f32de412f2b909eba7b4b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Try to get a file from cache or filesystem.  <a href="classstefanfrings_1_1TemplateLoader.html#a4d63f9937e5f32de412f2b909eba7b4b">More...</a><br /></td></tr>
<tr class="separator:a4d63f9937e5f32de412f2b909eba7b4b"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-attribs"></a>
Protected Attributes</h2></td></tr>
<tr class="memitem:aee91532454f736858307239c48c69523"><td class="memItemLeft" align="right" valign="top"><a id="aee91532454f736858307239c48c69523"></a>
QString&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstefanfrings_1_1TemplateLoader.html#aee91532454f736858307239c48c69523">templatePath</a></td></tr>
<tr class="memdesc:aee91532454f736858307239c48c69523"><td class="mdescLeft">&#160;</td><td class="mdescRight">Directory where the templates are searched. <br /></td></tr>
<tr class="separator:aee91532454f736858307239c48c69523"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a08d5758493b8e26f42f72799fed1caac"><td class="memItemLeft" align="right" valign="top"><a id="a08d5758493b8e26f42f72799fed1caac"></a>
QString&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstefanfrings_1_1TemplateLoader.html#a08d5758493b8e26f42f72799fed1caac">fileNameSuffix</a></td></tr>
<tr class="memdesc:a08d5758493b8e26f42f72799fed1caac"><td class="mdescLeft">&#160;</td><td class="mdescRight">Suffix to the filenames. <br /></td></tr>
<tr class="separator:a08d5758493b8e26f42f72799fed1caac"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2cb81190ac3993fda6e20e65713bfcce"><td class="memItemLeft" align="right" valign="top"><a id="a2cb81190ac3993fda6e20e65713bfcce"></a>
QTextCodec *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstefanfrings_1_1TemplateLoader.html#a2cb81190ac3993fda6e20e65713bfcce">textCodec</a></td></tr>
<tr class="memdesc:a2cb81190ac3993fda6e20e65713bfcce"><td class="mdescLeft">&#160;</td><td class="mdescRight">Codec for decoding the files. <br /></td></tr>
<tr class="separator:a2cb81190ac3993fda6e20e65713bfcce"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Loads localized versions of template files. </p>
<p>If the caller requests a file with the name "index" and the suffix is ".tpl" and the requested locale is "de_DE, de, en-US", then files are searched in the following order:</p>
<ul>
<li>index-de_DE.tpl</li>
<li>index-de.tpl</li>
<li>index-en_US.tpl</li>
<li>index-en.tpl</li>
<li>index.tpl</li>
</ul>
<p>The following settings are required: <code></p><pre>
path=../templates
suffix=.tpl
encoding=UTF-8
</pre><p></code> The path is relative to the directory of the config file. In case of windows, if the settings are in the registry, the path is relative to the current working directory. </p><dl class="section see"><dt>See also</dt><dd><a class="el" href="classstefanfrings_1_1TemplateCache.html" title="Caching template loader, reduces the amount of I/O and improves performance on remote file systems.">TemplateCache</a> </dd></dl>

<p class="definition">Definition at line <a class="el" href="templateloader_8h_source.html#l00040">40</a> of file <a class="el" href="templateloader_8h_source.html">templateloader.h</a>.</p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a25c1d61e6acd79e35feb71ac20751f30"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a25c1d61e6acd79e35feb71ac20751f30">&#9670;&nbsp;</a></span>TemplateLoader()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">TemplateLoader::TemplateLoader </td>
          <td>(</td>
          <td class="paramtype">const QSettings *&#160;</td>
          <td class="paramname"><em>settings</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">QObject *&#160;</td>
          <td class="paramname"><em>parent</em> = <code>nullptr</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Constructor. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">settings</td><td>configurations settings </td></tr>
    <tr><td class="paramname">parent</td><td>parent object </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="templateloader_8cpp_source.html#l00021">21</a> of file <a class="el" href="templateloader_8cpp_source.html">templateloader.cpp</a>.</p>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a20a9bf4c48bd07fe1c358d02b09d408a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a20a9bf4c48bd07fe1c358d02b09d408a">&#9670;&nbsp;</a></span>getTemplate()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classstefanfrings_1_1Template.html">Template</a> TemplateLoader::getTemplate </td>
          <td>(</td>
          <td class="paramtype">const QString&#160;</td>
          <td class="paramname"><em>templateName</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const QString&#160;</td>
          <td class="paramname"><em>locales</em> = <code>QString()</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Get a template for a given locale. </p>
<p>This method is thread safe. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">templateName</td><td>base name of the template file, without suffix and without locale </td></tr>
    <tr><td class="paramname">locales</td><td>Requested locale(s), e.g. "de_DE, en_EN". Strings in the format of the HTTP header Accept-Locale may be used. Badly formatted parts in the string are silently ignored. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>If the template cannot be loaded, an error message is logged and an empty template is returned. </dd></dl>

<p class="definition">Definition at line <a class="el" href="templateloader_8cpp_source.html#l00073">73</a> of file <a class="el" href="templateloader_8cpp_source.html">templateloader.cpp</a>.</p>

</div>
</div>
<a id="a4d63f9937e5f32de412f2b909eba7b4b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4d63f9937e5f32de412f2b909eba7b4b">&#9670;&nbsp;</a></span>tryFile()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">QString TemplateLoader::tryFile </td>
          <td>(</td>
          <td class="paramtype">const QString&#160;</td>
          <td class="paramname"><em>localizedName</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Try to get a file from cache or filesystem. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">localizedName</td><td>Name of the template with locale to find </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The template document, or empty string if not found </dd></dl>

<p>Reimplemented in <a class="el" href="classstefanfrings_1_1TemplateCache.html#a82621fb5262920f2dd981c5f0047db51">stefanfrings::TemplateCache</a>.</p>

<p class="definition">Definition at line <a class="el" href="templateloader_8cpp_source.html#l00051">51</a> of file <a class="el" href="templateloader_8cpp_source.html">templateloader.cpp</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>templateengine/<a class="el" href="templateloader_8h_source.html">templateloader.h</a></li>
<li>templateengine/<a class="el" href="templateloader_8cpp_source.html">templateloader.cpp</a></li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><b>stefanfrings</b></li><li class="navelem"><a class="el" href="classstefanfrings_1_1TemplateLoader.html">TemplateLoader</a></li>
    <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
  </ul>
</div>
</body>
</html>
